//
// Created by xili on 2024/9/2 18:32.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    long long maxArrayValue(vector<int> &nums) {
        int n = nums.size();
        long long sum = nums[n - 1];
        for (int i = n - 2; i >= 0; i--) {
            sum = sum < nums[i] ? nums[i] : sum + nums[i];
        }
        return sum;
    }
};